package com.zto.sch.base.event;

import com.zto.sch.base.event.two.CusEvent;
import com.zto.sch.base.event.two.CusEventListener;
import com.zto.sch.base.event.two.EventSourceObject;
import org.junit.Test;

import javax.swing.*;

/**
 * @program: sch-diy-parent
 * @description:
 * @author: sch
 * @create: 2020-11-28 17:46
 **/
public class TestAwtEvent {
    @Test
    public void testEventListener() {
        JButton jButton1 = new JButton("按钮1");
        JButton jButton2 = new JButton("按钮2");

        MyListener myListener = new MyListener();
        jButton1.addActionListener(myListener);
        jButton2.addActionListener(myListener);

        jButton1.doClick();

    }

    @Test
    public void diyEvent() {
        EventSourceObject object = new EventSourceObject();
        object.addCusListener(new CusEventListener(){
            @Override
            public void fireCusEvent(CusEvent e){
                super.fireCusEvent(e);
            }
        });

        object.setName("哈哈2");
    }
}
